home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / September 96 / Re A Fancier ListBox ? < prev    next >
Encoding:
Internet Message Format  |  1996-09-19  |  8.7 KB  |  [TEXT/ttxt]

  1. Subject:     Re: A Fancier ListBox ?
  2. Sent:        9/10/96 12:18 PM
  3. Received:    9/10/96 12:18 PM
  4. From:        mlanett@meer.net (Mark Lanett)
  5. Reply-To:    ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List
  7.  
  8.  
  9. >I have a need for a gadget that I can use to present a list of selections from
  10. >which one, or more, can be selected and then dragged out.  The FW_CListBox is
  11. >a simple wrapper to the Mac List Manager and doesn't not have this
  12. >functionality (not does it have some other little things I want, like allowing
  13. >me to show an icon beside the text, for example) so I am wondering what my
  14. >best next step should be.
  15.  
  16. You have two problems. One is that any work you do to FW_CListBox will be
  17. mac-specific and won't solve your Windows issue when R3 is released (and
  18. FW_CListBox wraps the Windows list box as well). Secondly, views can't do
  19. their own drag & drop; drag & drop only works at the frame level.
  20.  
  21. The first problem would be solved by writing a "table view" in C++, to ODF,
  22. which will work anywhere ODF is ported.
  23.  
  24. The second problem is solved either by embedding a different part (some
  25. sort of list part), or embedding one of your frames inside of itself, and
  26. then sticking the view in there. This will also solve the problem that
  27. non-platform-scrolling is limited to one view per frame. Alas we don't have
  28. any examples of how to do this, and it's really important, but it was
  29. discussed on the list earlier. Perhaps if Eudora's search function was less
  30. worthless I could even find it. <thrash thrash thrash> Ok, found it. See
  31. end of message.
  32.  
  33. We do have an unsupported table view class which was supposed to show up in
  34. the tool chest (http://www.devtools.apple.com/frameworks/odf/contrib/); I'm
  35. not sure why it isn't there.
  36.  
  37. Incidentally, while it would not be difficult to enhance FW_CListBox, we
  38. consider it undesirable to make functionality rely on features of platform
  39. controls which may not be available elsewhere. Likewise, drag & drop isn't
  40. available at the view level because views are intended to be more
  41. lightweight than frames, which can already do this.
  42.  
  43. ---------------------
  44.  
  45. Date: Thu, 13 Jun 1996 18:09:00 -0700
  46. Reply-To: ODF-Interest@CILabs.ORG
  47. Sender: owner-ODF-Interest@CILabs.ORG
  48. Precedence: list
  49. From: "Damon Cokenias" <cokenias@mtn-palace.com>
  50. To: OpenDoc Development Framework Discussion List <ODF-Interest@CILabs.ORG>
  51. Subject: Re: How to embed a part into yourself (long)
  52. Mime-Version: 1.0
  53. X-To: ODF-Interest@CILabs.ORG, fireboy@io.com
  54. X-Sender: mtn-3@SantaCruz01.pop.internex.net
  55.  
  56. >Can someone point me to sample code or a routine that shows how to create a
  57. >part at run-time and embed in another part. For example, in response to the
  58. >user choosing the text tool from a palette and dragging a rectangle, create
  59. >a text part and embed it at the location the user specified.
  60.  
  61. Mark, I meant to put together a little note about this just last week but
  62. forgot.  Sorry.
  63.  
  64. I've done this in one of our internal parts here at Apple.  There are a few
  65. steps, none too difficult.
  66.  
  67. First, create an ODShape to be used as the frame shape.  Remember that the
  68. top-left corner of a frame shape should be {0,0} regardless of where the
  69. part will appear in your content.  (More on location later).
  70.  
  71.  
  72.         FW_CAcquiredODShape     frameShape = FW_NewODShape (ev, bounds);
  73.  
  74. Second, you need to obtain a reference to your document's draft and ask the
  75. draft to create a new ODPart.  Given an FW_CPart, the following code will
  76. work:
  77.  
  78.         ODStorageUnit*          su = myPart -> GetStorageUnit (ev);
  79.         ODDraft*                draft = su -> GetDraft (ev);
  80.         FW_CAcquiredODPart      newPart = draft ->
  81.                                         CreatePart (ev, kTextKind, kODNoEditor);
  82.  
  83. Note that in the above code, kTextKind would be the full ISO string
  84. describing the kind of data to be embedded.  kODNoEditor signifies that
  85. OpenDoc should feel free to choose which editor to use for the embedded
  86. data.  Instead, this parameter could be an ISO string for a particular
  87. editor.
  88.  
  89. Third, you need to construct a proxy object to represent the embedded part
  90. within yor content model.  See ODFEmbed and ODFDraw for examples of proxy
  91. objects.  Depending on your content model you may need a very simple or
  92. very complicated proxy object.
  93.  
  94.         CMyProxy*               myProxy = new CMyProxy (ev, myPart,
  95.                                         myPart -> GetMainPresentation ());
  96.  
  97. Finally, embed the newly created part in your content:
  98.  
  99.         myPart -> GetMainPresentation () -> Embed (ev, newPart, NULL,
  100. kODFrameObject,
  101.                         myProxy, frameShape, FW_CPart::gViewAsFrameToken,
  102. NULL, 0,
  103.                         FALSE, FALSE);
  104.  
  105. These many parameters could use some explaining:
  106.  
  107. ev                      That obnoxious SOM thing that almost every function
  108. takes as a
  109.                         parameter
  110. newPart                 The ODPart created by our document's draft
  111. NULL                    The ODFrame to embed.  In our case, we want a frame
  112. created for
  113.                         us.
  114. kODFrameObject          Suggested frame type.
  115. myProxy                 The subclass of FW_MProxy that will represent the
  116. embedded
  117.                         content.
  118. frameShape              The frame shape, with its origin at {0,0}
  119. gViewAsFrameToken       A tokenized ISO string describing how to embed the
  120. part.  (As
  121.                         icon, thumbnail, frame, etc.)
  122. NULL                    Presentation type.  NULL for default.
  123. 0                       Frame group ID.
  124. FALSE                   Is overlaid
  125. FALSE                   Is subframe
  126.  
  127.  
  128.  
  129.  
  130. Once the above steps have been taken, the containing frame's
  131. CreateEmbeddedFacet method will be called.  This is where you decide where
  132. to position the embedded content and how much of it to display.
  133.  
  134. Often you will simply want a facet that is the same size and shape as the
  135. frame shape, just at a particular location in your frame.  The code below
  136. positions the embedded part at {40,100}.
  137.  
  138. ODFacet* CMyFrame::CreateEmbeddedFacet (Environment* ev, ODFacet*
  139. embeddingFacet,
  140.                 FW_MProxy* proxy, ODFrame* embeddedFrame,
  141.                 ODShape* proposedClipShape) {
  142.  
  143.         FW_CAcquiredODTransform                 externalTransform;
  144.  
  145.         externalTransform = ::FW_NewODTransform (ev, FW_CPoint
  146. (FW_IntToFixed (40),
  147.                 FW_IntToFixed (100)));
  148.  
  149.  
  150.         return embeddeingFacet -> CreateEmbeddedFacet (ev, embeddedFrame,
  151.                 proposedClipShape, externalTransform, NULL, NULL, NULL,
  152.                 kODFrameInFront);
  153. }
  154.  
  155. Once again, a quick breakdown of the parameters.  First, the values passed
  156. to CreateEmbeddedFacet:
  157.  
  158. ev              Your favorite and mine.
  159. embeddingFacet  The containing facet.
  160. proxy           Your subclass of FW_MProxy that was passed to
  161.                 FW_CEmbeddingPresentation::Embed in the code above.
  162. embeddedFrame   The frame of the embedded part that will draw in the facet
  163. you create.
  164. proposedClipShape       This shape describes the shape of the facet that
  165. the embedded
  166.                         part would prefer to use.  It is at {0,0}.
  167.  
  168.  
  169. The parameters to CreateEmbeddedFacet:
  170.  
  171. ev                      How much time gets spent passing this parameter anyway?
  172. embeddedFrame           The embedded frame
  173. proposedClipShape       The (in this case unaltered) shape to use.  If you
  174. want to use
  175.                         a shape other than the proposed shape, you should create
  176.                         another shape object, not mess with the
  177. proposedClipShape
  178.                         directly.
  179. externalTransform       Where in the parent facet (your part's facet) the
  180. embedded
  181.                         facet should appear.
  182. NULL                    The canvas.  NULL means use same canvas as
  183. containing part.
  184. NULL                    The biasCanvas.  NULL because we are not using any funky
  185.                         drawing coordinates.
  186. NULL                    A sibling facet.  If there is already a facet for this
  187.                         embedded frame, pass it here.
  188. kODFrameInFront         Where the facet should be in relation to its
  189. sibling.  This
  190.                         does not really apply in this situation because
  191. there is only
  192.                         one facet for this frame.
  193.  
  194.  
  195.  
  196. Whew!
  197.  
  198.  
  199.  
  200.  
  201. If you remove all of my comments and maybe fix a spelling error or two,
  202. you'll probably be able to compile the above directly in to your part.
  203.  
  204. I hope this was of help!
  205.  
  206. -Damon
  207. Quality ODF Guy
  208.  
  209.  
  210. +-----------------------------------------------------------------------+
  211. |   /\    Damon Cokenias                                                |
  212. |  /^^\   cokenias@mtn-palace.com                                       |
  213. | /____\  Visit the Mountain Palace at http://www.netgate.net/~cokenias |
  214. +-----------------------------------------------------------------------+
  215.  
  216. --
  217. Mark Lanett <mlanett@meer.net>
  218. Have a bajillion brilliant Jobsian lithium licks